package com.qmhl.toolposition.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.angcyo.tablayout.delegate2.ViewPager2Delegate
import com.qmhl.toolposition.R
import com.qmhl.toolposition.activity.MainActivity
import com.qmhl.toolposition.adapter.MsgAdapter
import com.qmhl.toolposition.databinding.FragmentMsgBinding
import com.qmhl.toolposition.databinding.ItemTabBinding

class AppMessageFragment : Fragment() {

    private lateinit var binding: FragmentMsgBinding
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View? {
        binding = FragmentMsgBinding.inflate(inflater, container, false)
        initData()
        initListener()
        return binding.root
    }

    private fun initListener() {
        
    }

    private fun initData() {
        binding.apply {
            vpMsg.offscreenPageLimit = indicatorTitles.size
            val mActivity = activity as MainActivity
            vpMsg.adapter = MsgAdapter(mActivity, indicatorTitles.size)
        }

//        for (i in indicatorTitles.indices) {
//            ItemTabBinding.inflate(layoutInflater).apply {
//                content.setText(indicatorTitles[i])
//                binding.dtMsg.addView(root)
//            }
//        }

        ViewPager2Delegate.install(binding.vpMsg, binding.dtMsg, false)


    }


    companion object {

        private val indicatorTitles = intArrayOf(
            R.string.msg_friend, R.string.msg_system
        )


    }
}